<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<!-- <script type="text/javascript" src="js/isWeixin.js"></script> -->
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<script type="text/javascript" src="js/flexible.min.js"></script>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="apple-touch-fullscreen" content="YES" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="format-detection" content="email=no" />
	<meta name="author" content="persona" />
	<link rel="shortcut icon" href="images/eCar_icon.png" type="image/png">
	<title>支付订单</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css">
	<style type="text/css">
		html {background-color: #F5F5F5;}
		body {font-family: PingFangSC-Regular,Verdana,Arial,"宋体","微软雅黑"; overflow: hidden;}
		.payment-message {width: 10rem; min-height: 2.66666666rem; margin: 0.13333333rem auto 0; font-size: 12px; background-color: #FFF; color: #505050; overflow: hidden;}
		[data-dpr="2"] .payment-message {font-size: 24px;}
		[data-dpr="3"] .payment-message {font-size: 36px;}
		.payment-message p {margin-left: 0.4rem;}
		.payment-message p:nth-child(1) {margin-top: 0.37333333rem; margin-bottom: 0.4rem;}
		.payment-message p:nth-child(3) {margin-top: 0.4rem; margin-bottom: 0.37333333rem;}
		.payment-title {width: 10rem; min-height: 0.96rem; line-height: 0.96rem; margin: 0.13333333rem auto 0; font-size: 14px; background-color: #FFF; overflow: hidden;}
		.payment-title p:nth-child(1) {width: 0.13333333rem; height: 0.64rem; margin: 0.16rem 0.26666666rem 0.16rem 0; background-color: #EA4040; float: left;}
		.payment-title p:nth-child(2) {color: #333; float: left;}
		.payment-style {width: 10rem; margin: 0 auto 0.53333333rem;}
		.payment-style li {width: 100%; margin-top: 0.02666666rem; background-color: #FFF;}
		.payment-style li img:nth-child(1) {width: 0.90666666rem; height: auto; padding: 0.32rem 0.32rem 0.29333333rem 0.4rem;}
		.payment-style div {display: inline-block; vertical-align: top;}
		.payment-style div p:nth-child(1) {font-size: 14px; color: #333; line-height: 0.45333333rem; margin: 0.29333333rem 0 0.13333333rem;}
		.payment-style div p:nth-child(2)  {font-size: 10px; color: #999; line-height: 1.2;}
		[data-dpr="2"] .payment-style div p:nth-child(2)  {font-size: 20px;}
		[data-dpr="3"] .payment-style div p:nth-child(2)  {font-size: 30px;}
		.payment-style li img:nth-child(3) {width: 0.37333333rem; height: auto; float: right; margin: 0.56rem 0.4rem 0 0;}
		.payment-style input {display: none;}
		
		[data-dpr="2"] .payment-title,[data-dpr="2"] .payment-style div p:nth-child(1) {font-size: 28px;}
		[data-dpr="3"] .payment-title,[data-dpr="3"] .payment-style div p:nth-child(1) {font-size: 42px;}
		.payment-next {width: 8.53333333rem; height: 1.17333333rem; line-height: 1.17333333rem; font-size: 16px; color: #FFF; text-align: center; background-color: #EA4040; margin: 0 auto; border-radius: 0.64rem; box-shadow: 0 0 0.10666666rem 0 #FF6B6B; -webkit-box-shadow: 0 0 0.10666666rem 0 #FF6B6B; -moz-box-shadow: 0 0 0.10666666rem 0 #FF6B6B;}
		[data-dpr="2"] .payment-next {font-size: 32px;}
		[data-dpr="3"] .payment-next {font-size: 48px;}
	</style>
</head>
<body>
	<div class="payment-message">
		<p><span>订单号：</span><span></span></p>
		<p><span>商品名称：</span><span>车险保费</span></p>
		<p><span>商品金额：</span><span></span></p>
	</div>
	<div class="payment-title">
		<p></p>
		<p>支付方式</p>
	</div>
	<div class="payment-style">
		<ul>
			<li>
				<img src="images/payment_wx.png" />
				<div>
					<p>微信支付</p>
					<p>安全支付</p>
				</div>
				<img class="payment-choice" src="images/payment_on.png" />
				<input type="radio" value="" name="choice" checked />
			</li>
			<!-- <li>
				<img src="images/payment_ali.png" />
				<div>
					<p>支付宝支付</p>
					<p>安全支付</p>
				</div>
				<img class="payment-choice" src="images/payment_un.png" />
				<input type="radio" value="" name="choice" />
			</li>
			<li>
				<img src="images/payment_union.png" />
				<div>
					<p>银行卡支付</p>
					<p>使用网上银行支付</p>
				</div>
				<img class="payment-choice" src="images/payment_un.png" />
				<input type="radio" value="" name="choice" />
			</li>
			<li>
				<img src="images/payment_kq.png" />
				<div>
					<p>快钱支付</p>
					<p>使用网上银行支付</p>
				</div>
				<img class="payment-choice" src="images/payment_un.png" />
				<input type="radio" value="" name="choice" />
			</li> -->
		</ul>
	</div>
	<p class="payment-next">下一步</p>
	<div class="black-bg"></div>

	<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript">
		$(window).load(function(){
			var thisURL = window.location.href;
			var orderNumber;
			var bizId;
			var couponId;
			if(thisURL.indexOf("?")>=0&&thisURL.indexOf("=")>=0){
				var thisSearch = thisURL.split('?')[1];
				console.log(thisSearch);
				var thisUrlArr = new Array();
				if(thisSearch.indexOf("&")>=0){
					thisSearch = thisSearch.split('&');
					for(var i in thisSearch){
						thisUrlArr.push(thisSearch[i].split('=')[0]);
						thisUrlArr.push(thisSearch[i].split('=')[1]);
					}
				}else{
					thisUrlArr = thisSearch.split('=');
				}
				console.log(thisUrlArr);
				for(var i=0; i<thisUrlArr.length;i++){
					if(thisUrlArr[i] == "bizId"){
						bizId = thisUrlArr[i+1];
					}else if(thisUrlArr[i] == "couponId"){
						couponId = thisUrlArr[i+1];
					}
					i+=1;
				}
				console.log(bizId);
				console.log(couponId);
				if(couponId == undefined || couponId == "undefined"){
					console.log("无优惠券");
				}
				// orderNumber = thisURL.split('?')[1].split('=')[1];
				// if(orderNumber && orderNumber !=""){
				// 	$(".payment-message p").eq(0).find("span").eq(1).html(orderNumber);
				// 	$.ajax({
				// 		type: "GET",
				// 		async: false,
				// 		url: "/order/pay/pay_info?orderNumber="+orderNumber,
				// 		success: function(data) {
				// 			console.log(data);
				// 			if(data.code == "0602"){
				// 				warnText($(".black-bg"),data.msg,2000);
				// 			}else{
				// 				var message = data.data;
				// 				var array = message.coupons;
				// 				if(array == null){//如果没有折扣券
				// 					var totalprice = message.totalPremium;
				// 				}
				// 				else{//如果有折扣券
				// 					var totalprice = array[0].preferentialPrice;
				// 				}
				// 				$(".payment-message p").eq(2).find("span").eq(1).html(totalprice+"元");
				// 			}
				// 		},
				// 		error: function(data){
				// 			console.log("获取失败：\n"+data);
				// 		}
				// 	})
				// }	
			}
			// 点击方式选择：触发赋值   style：wx al 银联 快捷
			// 改变支付方式的情况：图片的改变   enabled属性   赋值改变
			var payStyle;
			$(".payment-style li").on("click", function(){
				if($(this).find("input").prop("checked")){
					return false;
				}else{
					$(this).find("input").prop("checked",true);
					$(this).find(".payment-choice").attr("src", "images/payment_on.png");
					$(this).siblings("li").find(".payment-choice").attr("src", "images/payment_un.png");
				}
			})
			
			// 点击提交：获取支付方式的值并传值 ajax
			$(".payment-next").on("click", function(){
				if($(".payment-style li").eq(0).find("input").prop("checked")){
					payStyle = "cibwxh5";
				}
				// else if($(".payment-style li").eq(1).find("input").prop("checked")) {
				// 	alert("ali");
				// }else if($(".payment-style li").eq(2).find("input").prop("checked")) {
				// 	alert("union");
				// }else if($(".payment-style li").eq(3).find("input").prop("checked")) {
				// 	alert("kq");
				// }
				else {
					warnText($(".black-bg"),"您还有没选择支付方式！",1000);
				}
				var jsonData = {
					service: payStyle,
					orderId: orderNumber,
					callback_url: "http://wx.ydche.com/eInsurance/paysuc.html"
				};
				$.ajax({
					type: "POST",
					url: "http://176k5907u4.imwork.net/pay/gateway",
					async: true,
					data: jsonData,
					contentType: "application/x-www-form-urlencoded; charset=utf-8",
					dataType: "json",
					success: function(data) {
						if(data.code == "0000"){
							window.location.href = data.data;
						}
					},
					error: function(data){
						console.log("error:"+data.msg);
					}
				})
			})
		})
	</script>
</body>
</html>